package one.stand.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import one.stand.aop.ApiController;
import one.stand.model.ResultModel;
import one.stand.request.AddShareCountRequest;
import one.stand.request.CreateShareRecordRequest;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 分享记录 controller
 * Created by renz on 2019/10/23 23:06
 */
@RestController
@RequestMapping("userApi/shareRecord")
@Api(description = "分享记录系列",tags="分享记录系列")
public class ShareRecordController extends BaseController {

    @PostMapping("/addShareRecord")
    @ApiOperation(value = "添加分享记录")
    @ApiImplicitParams({
                         @ApiImplicitParam(name = "companyId", value = "被查看的企业ID", required = true, paramType = "Integer"),
                         @ApiImplicitParam(name = "shareType", value = "分享类型 1:名片，2:商品，3:预约，4:文章", required = true, paramType = "Integer"),
                         @ApiImplicitParam(name = "itemId", value = "分享对象id 名片id、商品id、预约产品id、文章id", required = true, paramType = "Integer"),
                         @ApiImplicitParam(name = "uuid", value = "前端生成的uuid", paramType = "String"),
    })
    @ApiController(isLogin = true, paramClass = CreateShareRecordRequest.class)
    public ResultModel<Integer> addShareRecord(@RequestAttribute CreateShareRecordRequest request) {
        request.setUserId(request.getId().intValue());
        request.setCardId(request.getMyCardId());
        return crmFegin.addShareRecord(request);
    }

    @PostMapping("/addOpenShareCount")
    @ApiOperation(value = "添加打开分享次数")
    @ApiImplicitParams({ @ApiImplicitParam(name = "shareRecordId", value = "分享Id", paramType = "Integer"),
                         @ApiImplicitParam(name = "uuid", value = "前端生成的uuid", paramType = "String") })
    @ApiController(paramClass = AddShareCountRequest.class)
    public ResultModel<Boolean> addOpenShareCount(@RequestAttribute AddShareCountRequest request) {
        return crmFegin.addOpenShareCount(request);
    }


}
